package com.yanu.trace.t2s.service.impl;

import com.yanu.trace.t2s.entity.Dept;
import com.yanu.trace.t2s.mapper.DeptMapper;
import com.yanu.trace.t2s.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeptServcieImpl implements DeptService {

    @Autowired
    DeptMapper deptMapper;

    @Override
    public Dept findByDeptno(int deptno) {
        return deptMapper.findByDeptno(deptno);
    }

    public List<Dept> findAll(){
        return  deptMapper.findAll();
    }

    @Override
    public List<Dept> findByIDL(int deptno, String dname, String loc) {
        dname = ( ( dname!=null  )&&( dname.trim().length() > 0)  )?     "%" + dname + "%"  : "" ;
        return deptMapper.findByIDL(deptno,dname, loc);
    }

    @Override
    public List<Dept> paging(int pageIndex  ,int pagesize ) {
        int begin  = (pageIndex - 1)* pagesize;
        return deptMapper.paging(begin,pagesize);
    }
}
